package cn.iocoder.yudao.module.dine.category.dao;

import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.business.basic.dao.mapper.CoreMapper;
import cn.iocoder.yudao.framework.business.basic.dao.query.CoreLambdaQueryWrapper;
import cn.iocoder.yudao.module.dine.category.convert.DineCategoryConvert;
import cn.iocoder.yudao.module.dine.category.pojo.po.DineCategory;
import cn.iocoder.yudao.module.dine.category.pojo.vo.DineCategoryVO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * <pre>
 * OOoO0OOoO0OOOooo0oOOOO0OOOOO0oooOO0ooOOO0Ooooo0OOOOo0ooooO0OOooo0Ooooo0OOOOO
 * Mapper 接口
 * OOoO0OOoO0OOOooo0oOOOO0OOOOO0oooOO0ooOOO0Ooooo0OOOOo0ooooO0OOooo0Ooooo0OOOOO
 * </pre>
 *
 * @author 山野羡民（1032694760@qq.com）
 * @since 2025/07/18
 */
@Mapper
public interface DineCategoryMapper extends CoreMapper<DineCategory> {

    default List<DineCategoryVO> selectEnableCategoryList(Long shopId) {
        CoreLambdaQueryWrapper<DineCategory> wrapper = new CoreLambdaQueryWrapper<>();
        wrapper.eq(DineCategory::getShopId, shopId);
        wrapper.eq(DineCategory::getEnabled, true);
        List<DineCategory> list = selectList(wrapper);
        if (CollUtil.isEmpty(list)) {
            return List.of();
        }
        return DineCategoryConvert.INSTANCE.toViewObject(list);
    }

}
